package com.junyu.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * springmvc配置类
 */
@Configuration
public class LoginWebConfigure implements WebMvcConfigurer {
    @Autowired
    private LoginInterceptor loginInterceptor;


    /**
     *注册拦截器
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor).addPathPatterns("/change/password", "/change/email", "/logout", "/login/count");
    }

    /**
     *发送邮件类相关配置
     */
    @Bean
    public JavaMailSender javaMailSender() {
        JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
        mailSender.setHost("smtp.qq.com");
        mailSender.setPort(587);
        mailSender.setUsername("1741141989@qq.com");
        mailSender.setPassword("jxtuvmndnbupbbbh");
        return mailSender;
    }
}
